import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { viteMockServe } from 'vite-plugin-mock'

// https://vitejs.dev/config/
export default ({ command }) => {
  return defineConfig({
    plugins: [
      vue(),
      viteMockServe({
        mockPath: './src/mock',
        localEnabled: command == 'serve',
      }),
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
    resolve: {
      alias: {
        '@': resolve(__dirname, './src'),
      },
    },
    server: {
      port: 82,
      cors: true,
      proxy: {
        '/aaa': {
          target: 'http://****/',
          changeOrigin: true,
          configure: (proxy, options) => {},
        },
      },
    },
  })
}
